package com.pwt.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
 * @author dw
 * @version 1.0.0
 * @date 2021/10/13
 */
public class DoubleUtils {

    public static Double  retain2(Double d){
        if(d == null){
            return 0.00D;
        }
        DecimalFormat decimalFormat = new DecimalFormat("#.00");
        return Double.parseDouble(decimalFormat.format(d));
    }

    public static Double  retainPercent2(Double d){
        if(d == null){
            return 0.00D;
        }
        d = d* 100;
        DecimalFormat decimalFormat = new DecimalFormat("#.00");
        return Double.parseDouble(decimalFormat.format(d));
    }

}
